A whole number between lo and hi, both ends included - roll_int(1, 6) is a dice roll, roll_int(-1, 1) is a step either way or none at all.
roll_int(lo, hi) -> int| Name | Type |
|---|---|
lo | int |
hi | int |
int
A whole number somewhere between lo and hi, with both ends included - roll_int(1, 6) is a dice roll that can come up 1 or 6, and roll_int(-1, 1) is a step left, right, or nowhere.
Every function in this family includes both ends, so roll_int(0, 5) and roll_real(0, 5) mean the same range and differ only in the kind of number they hand back. There is no half-open sibling to remember.
Reach for this one whenever the value is a count, an index or a frame number, and for roll_real whenever it feeds something continuous - an angle, a speed, a scale.
frame = roll_int(0, 2);Picks one frame of a three-frame torch sprite each step, so a row of torches never burns in lockstep. roll_int(0, 2) can return 0, 1 or 2 - three values, because both ends count.
lo equal to hi is a legal one-value range, not an error - and it costs no draw at all, so a range that has collapsed to a single value never shifts every later roll along the stream.hi below lo) describes the same set of numbers read the other way, and is answered that way. It is never clamped to one end, which would discard one of your arguments.A Game Boy Advance has no clock to seed from, and Gbabel never reseeds anything, so two runs of the same ROM roll the same numbers in the same order. That is deliberate: a bug that only shows up on one unlucky roll can be reproduced by playing the same way again, and a recording of a scene is frame-for-frame the same every time.
roll_reseed is how a project asks for a different game each time instead.
A save file does not carry the roll stream. Loading a save picks up wherever the current run has got to, not wherever the save was made - so never rebuild saved world state out of rolls. Save what was decided, never the seed that decided it.
Every roll_ call in a project draws from one shared stream, so they interleave: a roll_int here advances the same sequence a roll_chance elsewhere reads next.
Particle jitter and camera_shake keep their own separate streams and are untouched by anything here, roll_reseed included. That is on purpose: if they shared this stream, adding a single roll_int call anywhere would change every particle and every shake frame in the whole game.
One draw from the project-wide stream per call. lo == hi is a legal one-value range and costs no draw at all; a range written the wrong way round (hi below lo) describes the same set of numbers and is answered that way, never clamped to one end. Rolls repeat: the same ROM rolls the same numbers in the same order every run unless something calls roll_reseed.